package com.java.zhuiyun.api.sysdict.mapper;

import com.java.zhuiyun.api.sysdict.entity.SysDict;
import com.java.zhuiyun.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName SysDictMapper
 * @Description TODO
 * @Author xy
 * @Date 2023/8/15 11:42
 **/
@Mapper
public interface SysDictMapper extends BaseMapper<SysDict> {
    /**
    * @Author xy
    * @Description 全查
    * @Date 2023/8/15 14:15
    * @Return  * @param null
    */
    @Select("<script>select * from sys_dict where del_flag = 0 " +
            "<when test='dictName != null and dictName != &quot;&quot;'> " +
            "and dict_name like concat('%', #{dictName}, '%') </when>" +
            "<when test='dictType != null and dictType != &quot;&quot;'> " +
            "and dict_type like concat('%', #{dictType}, '%') </when> </script>")
    List<SysDict> dictList(SysDict sysDict);

    /**
    * @Author xy
    * @Description 添加
    * @Date 2023/8/15 15:35
    * @Return  * @param null
    */
    @Insert("insert into sys_dict (dict_name,dict_value,dict_type,create_time,update_time,del_flag) values " +
            "(#{dictName},#{dictValue},#{dictType},#{createTime},#{updateTime},#{delFlag})")
    int SysDictAdd(SysDict sysDict);

    /**
    * @Author xy
    * @Description 逻辑删除
    * @Date 2023/8/15 16:41
    * @Return  * @param null
    */
    @Update("update sys_dict set del_flag = 1 where id = #{id}")
    int SysDictDelete(Integer id);
}
